#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1410;
const int inf = 0x3f3f3f3f;

struct element{
	int a,b,c,id;
}ele[N];
bool operator < (element x,element y){return x.c < y.c;}

struct edge{int v,w,nxt;}e[(N*N)<<2];
int S,T,h[N],f[N],cnt,edid[N],n,to[N],ot[N],d[N],now[N];
void link(int x,int y,int w){e[++cnt] = (edge){y,w,h[x]};h[x] = cnt;e[++cnt] = (edge){x,0,h[y]};h[y] = cnt;}

void clear(){
	memset(h,0,sizeof(h)); cnt = 1;
}

bool bfs(int s,int t){
	memset(d,0,sizeof(d)); d[s] = 1; queue<int> q; q.push(s); now[s] = h[s];
	while(q.size()){
		int x = q.front();q.pop();
		for(int i = h[x],y;i;i = e[i].nxt){
			if(!d[y = e[i].v] && e[i].w){
				d[y] = d[x] + 1; q.push(y); now[y] = h[y];
				q.push(y); if(y == t) return 1;
			}
		}
	}return 0;
}

int dfs(int x,int flow,int t){
	if(x == t) return flow; int res = flow;
	for(int i = now[x],y;i && res;i = e[i].nxt){
		now[x] = i;
		if(d[y = e[i].v] == d[x] + 1 && e[i].w){
			int k = dfs(y,min(res,e[i].w),t);
			if(!k) d[y] = 0; res -= k; e[i].w -= k; e[i^1].w += k;
		}
	}
	return flow - res;
}

bool check(int s,int t){
	static bool vis[N]; memset(vis,0,sizeof(vis));
	vis[s] = 1; queue<int> q; q.push(s);
	while(q.size()){
		int x = q.front(); q.pop();
		for(int i = h[x],y;i;i = e[i].nxt){
			if(e[i].w && !vis[y = e[i].v]) {vis[y] = 1,q.push(y);if(y == t) return 1;}
		}
	}return 0;
}

void solve(){
	n = in; for(int i = 1;i <= n;i++) ele[i].a = in,ele[i].id = i;
	for(int i = 1;i <= n;i++) ele[i].b = in;
	for(int i = 1;i <= n;i++) ele[i].c = in;
	int ml = 0;
	for(int i = 1;i <= n;i++){
		f[i] = 1;
		for(int j = 1;j < i;j++)
			if(ele[j].a < ele[i].a)
				f[i] = max(f[i],f[j]+1);
		ml = max(f[i],ml);
	}
	S = 0; T = 2 * n + 1;
	for(int i = 1;i <= n;i++){
		to[i] = i; ot[i] = i + n;
		link(to[i],ot[i],ele[i].b);
		edid[i] = cnt;
		if(f[i] == 1) link(S,to[i],inf);
		else if(f[i] == ml) link(ot[i],T,inf);
	}
	for(int i = 1;i <= n;i++)
		for(int j = i+1;j <= n;j++)
			if(ele[i].a < ele[j].a && f[i] + 1 == f[j]) link(ot[i],to[j],inf);
	int flow = 0;
	ll maxflow = 0;
	while(bfs(S,T)) while(flow = dfs(S,inf,T)) maxflow += flow;
	printf("%lld ",maxflow);
	vector<int> del;
	sort(ele+1,ele+n+1);
	for(int i = 1;i <= n;i++){
		int id = ele[i].id;
		if(check(to[id],ot[id])) continue;
		del.pb(id);
		while(bfs(to[id],S)) dfs(to[id],inf,S);
		while(bfs(T,ot[id])) dfs(T,inf,ot[id]);
		e[edid[id]].w = e[edid[id]^1].w = 0;
	}
	printf("%lu\n",del.size()); sort(del.begin(),del.end());
	for(int x : del) printf("%d ",x);
	puts("");
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	for(int test = in;test;test--) clear(),solve();
	return 0;
}
